/*
 *  Copyright (c) 2023 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
 *
 *  This program and the accompanying materials are made available under the
 *  terms of the Apache License, Version 2.0 which is available at
 *  https://www.apache.org/licenses/LICENSE-2.0
 *
 *  SPDX-License-Identifier: Apache-2.0
 *
 *  Contributors:
 *       Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - initial API and implementation
 *
 */

package org.eclipse.edc.validator.dataaddress.httpdata;

import org.eclipse.edc.dataaddress.httpdata.spi.HttpDataAddressSchema;
import org.eclipse.edc.runtime.metamodel.annotation.Extension;
import org.eclipse.edc.runtime.metamodel.annotation.Inject;
import org.eclipse.edc.spi.system.ServiceExtension;
import org.eclipse.edc.spi.system.ServiceExtensionContext;
import org.eclipse.edc.validator.spi.DataAddressValidatorRegistry;

import static org.eclipse.edc.validator.dataaddress.httpdata.HttpDataDataAddressValidatorExtension.NAME;

@Extension(NAME)
public class HttpDataDataAddressValidatorExtension implements ServiceExtension {
    public static final String NAME = "DataAddress HttpData Validator";

    @Inject
    private DataAddressValidatorRegistry dataAddressValidatorRegistry;

    @Override
    public void initialize(ServiceExtensionContext context) {
        var validator = new HttpDataDataAddressValidator();
        dataAddressValidatorRegistry.registerSourceValidator(HttpDataAddressSchema.HTTP_DATA_TYPE, validator);
        dataAddressValidatorRegistry.registerDestinationValidator(HttpDataAddressSchema.HTTP_DATA_TYPE, validator);
    }
}
